<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
</head>
<body>
    <h2>头像</h2>
    <hr />
    <form action="index.php" method="get" enctype="multipart/form-data">
        <input type="file" id="file" name="pic[]" multiple onchange="abc(event)">
        <br />
        <input type="submit" id="" value="提交" />
        <br />
        <img id="imgBase"  width="200px" height="200px" >
    </form>
</body>
<script>
    function abc(event){
        // var files=document.getElementById('file').files;//获取input的上传文件数组 和下一行是一样的
        var files = event.target.files;
        var URL = window.URL || window.webkitURL;
        var imgURL = URL.createObjectURL(files[0]);
        document.getElementById('imgBase').src=imgURL;
    }
</script>
</html>

<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/12/2
 * Time: 10:39
 */